package com.example.ItPhotoAlbumCloud.utils;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


/**
 * 分页返回模型
 * 小仙 创建人 2023-03-12 08:36:32.
 */
public class PaginationResult extends ToString {

    public PaginationResult(Object data, Pagination pagination){
        this.data = data;
        this.pagination = pagination;
    }

    public PaginationResult(Object data, Pagination pagination, long total){
        this.data = data;
        this.pagination = pagination;
        this.pagination.setTotal(total);
    }

    public PaginationResult(Object data, JSONObject request, long total){
        this.data = data;
        this.pagination = JSON.toJavaObject(request, Pagination.class);
        if (null != this.pagination){
            this.pagination.setTotal(total);
        }
    }


    /** 数据 */
    private Object data;

    /** 分页对象 */
    private Pagination pagination;

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Pagination getPagination() {
        return pagination;
    }

    public void setPagination(Pagination pagination) {
        this.pagination = pagination;
    }
}

